package com.guoxin.concurrentprogramming.chapter2;

import java.util.concurrent.TimeUnit;

/**
 * @author guoxin
 * @date 2019/7/15
 */
public class DaemonThread {

    private static class DaemonT extends Thread {
        @Override
        public void run() {
            while (true){
                try {
                    System.out.println("I'm alive");
                    TimeUnit.SECONDS.sleep(1);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
            }
        }
    }

    public static void main(String[] args) throws InterruptedException {
        DaemonT dt = new DaemonT();
        dt.setDaemon(true);
        dt.start();

        TimeUnit.SECONDS.sleep(5);

    }
}
